﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary">

    <!--Brushes-->
    <SolidColorBrush x:Key="RibbonBackgroundBrushKey" 
                     Color="#DFE9F5" />
    <SolidColorBrush x:Key="DisabledBackgroundBrushKey" 
                     Color="#EEE" />
    <SolidColorBrush x:Key="DisabledBorderBrushKey" 
                     Color="#AAA" />
    <SolidColorBrush x:Key="InControlGroupBorderBrushKey" 
                     Color="#ADBED6" />
    <LinearGradientBrush x:Key="GroupHostBackgroundBrushKey" 
                         StartPoint="0.5,0.0" 
                         EndPoint="0.5,1.0">
        <GradientStop Color="White" Offset="0.0" />
        <GradientStop Color="#DBE7F4" Offset="1.0" />
    </LinearGradientBrush>
    <SolidColorBrush x:Key="RibbonFontColorBrushKey"
                     Color="#1E395B" />
    <SolidColorBrush x:Key="InControlGroupSeparatorBrushKey"
                     Color="#C6CFDE" />
    <LinearGradientBrush x:Key="InControlGroupIsMouseOverBackgroundBrushKey" 
                         StartPoint="0,0" 
                         EndPoint="0,1">
        <GradientStop Offset="0" Color="#FFF3E7" />
        <GradientStop Offset="0.36" Color="#FFDFBD" />
        <GradientStop Offset="0.36" Color="#FFCF6B" />
        <GradientStop Offset="1" Color="#FFF3AD" />
    </LinearGradientBrush>
    <SolidColorBrush x:Key="InControlGroupSeparatorIsMouseOverBrushKey"
                     Color="#E7BE6B" />
    <LinearGradientBrush x:Key="InControlGroupIsPressedBackgroundBrushKey"
                         StartPoint="0,0"
                         EndPoint="0,1">
        <GradientStop Offset="0" Color="#D6C3AD" />
        <GradientStop Offset="0.05" Color="#EFCBA5" />
        <GradientStop Offset="0.36" Color="#EFC78C" />
        <GradientStop Offset="0.36" Color="#EFBE63" />
        <GradientStop Offset="1" Color="#EFF3B5" />
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="InControlGroupIsPressedBorderBrushKey"
                         StartPoint="0,0"
                         EndPoint="0,1">
        <GradientStop Offset="0" Color="#C69239" />
        <GradientStop Offset="1" Color="#C6B65A" />
    </LinearGradientBrush>
    <SolidColorBrush x:Key="RibbonTextBoxBorderBrushKey" 
                     Color="#ADBAD6" />
    <SolidColorBrush x:Key="RibbonTextBoxBackgroundBrushKey"
                     Color="#F7F7FF" />
    <SolidColorBrush x:Key="RibbonTextBoxDisabledBorderBrushKey"
                     Color="#B1BBC6" />
    <SolidColorBrush x:Key="RibbonTextBoxDisabledBackgroundBrushKey"
                     Color="#EFEFEF" />
    <SolidColorBrush x:Key="RibbonDownArrowBrushKey" 
                     Color="#4D6176" />
    
    <!---->
    <!--ControlTemplates-->
    <!---->
    
    <!--ImageButton Template-->
    <ControlTemplate x:Key="btnImg" TargetType="{x:Type Button}">
        <Border x:Name="mBorder" 
                SnapsToDevicePixels="true" 
                BorderThickness="1" 
                BorderBrush="{StaticResource InControlGroupBorderBrushKey}">
            <Border x:Name="iBorder" 
                    BorderThickness="0" 
                    BorderBrush="{TemplateBinding BorderBrush}" 
                    SnapsToDevicePixels="true">
                <Image x:Name="image"
                       Width="16" 
                       Height="16"
                       Source="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}, Path=ImageSource}"/>
            </Border>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" 
                     Value="true">
                <Setter TargetName="mBorder"
                        Property="Background" 
                        Value="{StaticResource InControlGroupIsMouseOverBackgroundBrushKey}"/>
                <Setter TargetName="iBorder"
                        Property="BorderBrush"
                        Value="{StaticResource InControlGroupSeparatorIsMouseOverBrushKey}"  />
            </Trigger>
            <Trigger Property="IsPressed" 
                     Value="true">
                <Setter Property="BorderBrush"
                        Value="{StaticResource InControlGroupIsPressedBorderBrushKey}"  />
                <Setter TargetName="mBorder" 
                        Property="Background"
                        Value="{StaticResource InControlGroupIsPressedBackgroundBrushKey}"  />
                <Setter TargetName="mBorder" 
                        Property="BorderBrush"
                        Value="{StaticResource InControlGroupBorderBrushKey}" />
                <Setter TargetName="iBorder" 
                        Property="BorderBrush"
                        Value="{StaticResource InControlGroupSeparatorIsMouseOverBrushKey}" />
            </Trigger>
            <Trigger Property="IsEnabled" 
                     Value="false">
                <Setter TargetName="image" 
                        Property="Opacity" 
                        Value="0.4" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    
    <!--ImageButtonFlat Template-->
    <ControlTemplate x:Key="btnImgFlat" TargetType="{x:Type Button}">
        <Border x:Name="mBorder" 
                SnapsToDevicePixels="true" 
                BorderThickness="0" 
                BorderBrush="Transparent">
            <Border x:Name="iBorder" 
                    BorderThickness="0" 
                    BorderBrush="{TemplateBinding BorderBrush}" 
                    SnapsToDevicePixels="true">
                <Image x:Name="image"
                       Width="16" 
                       Height="16"
                       Source="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}, Path=ImageSource}"/>
            </Border>
        </Border>
        
    </ControlTemplate>

    <Style TargetType="{x:Type TabControl}">
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabControl}">
                    <Grid KeyboardNavigation.TabNavigation="Local">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <TabPanel x:Name="HeaderPanel"
                                  Grid.Row="0"
                                  Panel.ZIndex="1" 
                                  Margin="0,0,4,-1" 
                                  IsItemsHost="True"
                                  KeyboardNavigation.TabIndex="1"
                                  Background="Transparent" />
                        <Border x:Name="Border"               
                                Grid.Row="1" 
                                Background="{StaticResource RibbonTextBoxBackgroundBrushKey}" 
                                BorderBrush="{StaticResource InControlGroupBorderBrushKey}" 
                                BorderThickness="1" 
                                CornerRadius="2"
                                KeyboardNavigation.TabNavigation="Local"
                                KeyboardNavigation.DirectionalNavigation="Contained"
                                KeyboardNavigation.TabIndex="2">
                            <ContentPresenter Name="PART_SelectedContentHost"
                                              Margin="4"
                                              ContentSource="SelectedContent"/>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground" 
                                    Value="Yellow" />
                            <Setter TargetName="Border" 
                                    Property="BorderBrush" 
                                    Value="{StaticResource InControlGroupBorderBrushKey}" />
                        </Trigger>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self},Path=Items.Count}" Value="0">
                            <Setter TargetName="Border" 
                                    Property="Background" 
                                    Value="Transparent"/>
                            <Setter TargetName="Border" 
                                    Property="BorderBrush"
                                    Value="Transparent"/>
                        </DataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <!--RibbonWindow Style-->
    <Style  x:Key="rWindow" TargetType="{x:Type ribbon:RibbonWindow}">
        <Setter Property="Background" Value="{StaticResource RibbonBackgroundBrushKey}"/>
        <Setter Property="MinWidth" Value="350"/>
        <Setter Property="MinHeight" Value="270"/>
    </Style>
    <!--Window Style-->
    <Style x:Key="Window"  TargetType="{x:Type Window}">
        <Setter Property="Background" Value="{StaticResource RibbonBackgroundBrushKey}"/>
        <Setter Property="MinWidth" Value="0"/>
        <Setter Property="MinHeight" Value="0"/>
    </Style>
    <!--Button Style-->
    <Style TargetType="{x:Type Button}">
        <Setter Property="Background" Value="{StaticResource GroupHostBackgroundBrushKey}" />
        <Setter Property="HorizontalAlignment" Value="left" />
        <Setter Property="Focusable" Value="False"/>
        <Setter Property="Foreground" Value="{StaticResource RibbonFontColorBrushKey}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Border Name="TopAndBottomBorder" BorderThickness="1" BorderBrush="{StaticResource InControlGroupBorderBrushKey}" SnapsToDevicePixels="true">
                        <Border Name="InnerRight" BorderThickness="0" BorderBrush="{StaticResource InControlGroupSeparatorBrushKey}" SnapsToDevicePixels="true">
                            <Border Name="InnerLeftTopBottom" BorderThickness="0" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
                                <TextBlock Name="innerText" Text="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                            </Border>
                        </Border>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter TargetName="InnerLeftTopBottom" Value="{StaticResource InControlGroupIsMouseOverBackgroundBrushKey}" Property="Background" />
                            <Setter TargetName="InnerRight" Value="{StaticResource InControlGroupSeparatorIsMouseOverBrushKey}" Property="BorderBrush" />
                        </Trigger>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter Value="{StaticResource InControlGroupIsPressedBorderBrushKey}" Property="BorderBrush" />
                            <Setter TargetName="InnerLeftTopBottom" Value="{StaticResource InControlGroupIsPressedBackgroundBrushKey}" Property="Background" />
                            <Setter TargetName="InnerLeftTopBottom" Value="{StaticResource InControlGroupIsPressedBackgroundBrushKey}" Property="BorderBrush" />
                            <Setter TargetName="InnerRight" Value="{StaticResource InControlGroupSeparatorIsMouseOverBrushKey}" Property="BorderBrush" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter TargetName="innerText" Property="Opacity" Value="0.4" />
                        </Trigger>
                    </ControlTemplate.Triggers>

                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <!--ComboBox Style-->
    <Style x:Key="{x:Type ComboBox}" TargetType="ComboBox">
        <Setter Property="SnapsToDevicePixels" Value="true"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
        <Setter Property="Focusable" Value="true"/>
        <Setter Property="MinWidth" Value="120"/>
        <Setter Property="MinHeight" Value="20"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ComboBox">
                    <Grid>
                        <ToggleButton 
                            Name="ToggleButton" 
                            Template="{StaticResource ComboBoxToggleButton}" 
                            Grid.Column="2" 
                            Focusable="true"
                            IsChecked="{Binding Path=IsDropDownOpen,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}"
                            ClickMode="Press">
                        </ToggleButton>
                        <ContentPresenter Name="ContentSite"
                                          IsHitTestVisible="False" 
                                          Content="{TemplateBinding SelectionBoxItem}"
                                          ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
                                          ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
                                          Margin="3,3,23,3"
                                          VerticalAlignment="Center"
                                          HorizontalAlignment="Left" />
                        <TextBox x:Name="PART_EditableTextBox"
                                 Style="{x:Null}" 
                                 Template="{StaticResource ComboBoxTextBox}" 
                                 HorizontalAlignment="Left" 
                                 VerticalAlignment="Center" 
                                 Margin="3,0,23,3"
                                 Focusable="True" 
                                 Background="Transparent"
                                 Foreground="{StaticResource RibbonFontColorBrushKey}"
                                 Visibility="Hidden"
                                 IsReadOnly="{TemplateBinding IsReadOnly}"/>
                        <Popup Name="Popup"
                               Placement="Bottom"
                               IsOpen="{TemplateBinding IsDropDownOpen}"
                               AllowsTransparency="True" 
                               Focusable="False"
                               PopupAnimation="Slide">
                            <Grid Name="DropDown"
                                  SnapsToDevicePixels="True"                
                                  MinWidth="{TemplateBinding ActualWidth}"
                                  MaxHeight="{TemplateBinding MaxDropDownHeight}">
                                <Border x:Name="DropDownBorder"
                                        Background="{StaticResource RibbonTextBoxBackgroundBrushKey}"
                                        BorderThickness="1"
                                        BorderBrush="{StaticResource InControlGroupBorderBrushKey}"/>
                                <ScrollViewer Margin="4,6,4,6" 
                                              SnapsToDevicePixels="True">
                                    <StackPanel IsItemsHost="True" 
                                                KeyboardNavigation.DirectionalNavigation="Contained" />
                                </ScrollViewer>
                            </Grid>
                        </Popup>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="HasItems" 
                                 Value="false">
                            <Setter TargetName="DropDownBorder"
                                    Property="MinHeight"
                                    Value="95"/>
                        </Trigger>
                        <Trigger Property="IsEnabled"
                                 Value="false">
                            <Setter Property="Foreground" 
                                    Value="Green"/>
                        </Trigger>
                        <Trigger Property="IsGrouping"
                                 Value="true">
                            <Setter Property="ScrollViewer.CanContentScroll"
                                    Value="false"/>
                        </Trigger>
                        <Trigger SourceName="Popup" 
                                 Property="Popup.AllowsTransparency"
                                 Value="true">
                            <Setter TargetName="DropDownBorder" 
                                    Property="CornerRadius"
                                    Value="0"/>
                            <Setter TargetName="DropDownBorder"
                                    Property="Margin"
                                    Value="0,1,0,0"/>
                        </Trigger>
                        <Trigger Property="IsEditable"
                                 Value="true">
                            <Setter Property="IsTabStop" 
                                    Value="false"/>
                            <Setter TargetName="PART_EditableTextBox"
                                    Property="Visibility"	
                                    Value="Visible"/>
                            <Setter TargetName="ContentSite"
                                    Property="Visibility"
                                    Value="Hidden"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
        </Style.Triggers>
    </Style>
    <!--ComboBoxItem Style-->
    <Style x:Key="{x:Type ComboBoxItem}" TargetType="ComboBoxItem">
        <Setter Property="SnapsToDevicePixels" Value="true"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ComboBoxItem">
                    <Border 
                        Name="Border"
                        Padding="2"
                        SnapsToDevicePixels="true">
                        <ContentPresenter />
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsHighlighted" Value="true">
                            <Setter TargetName="Border" 
                                    Property="Background"
                                    Value="{StaticResource InControlGroupIsPressedBackgroundBrushKey}"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="Black"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <!--ComboBoxTextBox Template-->
    <ControlTemplate x:Key="ComboBoxTextBox" TargetType="TextBox">
        <Border x:Name="PART_ContentHost" Focusable="False" Background="{TemplateBinding Background}" />
    </ControlTemplate>
    <!--ComboBoxToggleButton Template-->
    <ControlTemplate x:Key="ComboBoxToggleButton" TargetType="ToggleButton">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition Width="18" />
            </Grid.ColumnDefinitions>
            <Border x:Name="Border" 
                    Grid.ColumnSpan="2"                    
                    Background="{StaticResource RibbonTextBoxBackgroundBrushKey}"
                    BorderBrush="{StaticResource InControlGroupBorderBrushKey}"
                    BorderThickness="1" />
            <Border Grid.Column="0"                    
                    Margin="1" 
                    Background="{StaticResource RibbonTextBoxBackgroundBrushKey}" 
                    BorderBrush="{StaticResource InControlGroupBorderBrushKey}"
                    BorderThickness="0,0,1,0" />
            <Path x:Name="Arrow"
                  Grid.Column="1"     
                  Fill="{StaticResource RibbonDownArrowBrushKey}"
                  HorizontalAlignment="Center"
                  VerticalAlignment="Center"
                  Data="M 0 0 L 4 4 L 8 0 Z"/>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="ToggleButton.IsMouseOver"
                     Value="true">
                <Setter TargetName="Border"
                        Property="Background" 
                        Value="{StaticResource InControlGroupIsMouseOverBackgroundBrushKey}" />
            </Trigger>
            <Trigger Property="ToggleButton.IsChecked"
                     Value="true">
                <Setter TargetName="Border"
                        Property="Background"
                        Value="{StaticResource InControlGroupIsPressedBackgroundBrushKey}" />
            </Trigger>
            <!--<Trigger Property="IsEnabled"
                     Value="False">
                <Setter TargetName="Border"
                        Property="Background"
                        Value="Black" />
                <Setter TargetName="Border"
                        Property="BorderBrush"
                        Value="Black" />
                <Setter Property="Foreground"
                        Value="Black"/>
                <Setter TargetName="Arrow" 
                        Property="Fill"
                        Value="Black" />
            </Trigger>-->
        </ControlTemplate.Triggers>
    </ControlTemplate>
    <!--TextBox Style-->
    <Style TargetType="{x:Type TextBox}">
        <Setter Property="Background" 
                Value="{StaticResource RibbonTextBoxBackgroundBrushKey}"/>
        <Setter Property="BorderBrush"
                Value="{StaticResource RibbonTextBoxBorderBrushKey}"/>
        <Setter Property="Foreground" 
                Value="{StaticResource RibbonFontColorBrushKey}"/>
        <Setter Property="BorderThickness"
                Value="1"/>
        <Setter Property="MinWidth"
                Value="120"/>
        <Setter Property="MinHeight"
                Value="20"/>
        <!--<Style.Triggers>
            <Trigger Property="IsEnabled" Value="True">
                <Setter Property="Background" 
                        Value="{StaticResource RibbonTextBoxBackgroundBrushKey}"/>
                <Setter Property="BorderBrush"
                        Value="{StaticResource RibbonTextBoxBorderBrushKey}"/>
                <Setter Property="Foreground" 
                        Value="{StaticResource RibbonFontColorBrushKey}"/>
            </Trigger>
        </Style.Triggers>-->
    </Style>
    <!--PasswordBox Style-->
    <Style TargetType="{x:Type PasswordBox}">
        <Setter Property="Background" 
                Value="{StaticResource RibbonTextBoxBackgroundBrushKey}" />
        <Setter Property="BorderBrush"
                Value="{StaticResource RibbonTextBoxBorderBrushKey}"/>
        <Setter Property="BorderThickness"
                Value="1"/>
        <Style.Triggers>
            <!--<Trigger Property="IsEnabled" Value="True">
                <Setter Property="Background" 
                        Value="{StaticResource RibbonTextBoxBackgroundBrushKey}"/>
                <Setter Property="BorderBrush"
                        Value="{StaticResource RibbonTextBoxBorderBrushKey}"/>
                <Setter Property="Foreground" 
                        Value="{StaticResource .RibbonFontColorBrushKey}"/>
            </Trigger>-->
            <!--<Trigger Property="IsEnabled" Value="False">
                <Setter Property="Background" 
                         Value="{StaticResource RibbonTextBoxDisabledBackgroundBrushKey}"/>
                <Setter Property="BorderBrush"
                        Value="{StaticResource RibbonTextBoxDisabledBorderBrushKey}"/>
            </Trigger>-->
        </Style.Triggers>
    </Style>
    <!--GroupBox Style-->
    <Style TargetType="{x:Type GroupBox}">
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Foreground" Value="{StaticResource RibbonFontColorBrushKey}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type GroupBox}">
                    <Grid SnapsToDevicePixels="true">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="6" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="6" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                            <RowDefinition Height="6" />
                        </Grid.RowDefinitions>
                        <Border Grid.ColumnSpan="4"
                                Grid.RowSpan="4" 
                                Background="{StaticResource GroupHostBackgroundBrushKey}"
                                CornerRadius="4,4,4,4" 
                                BorderThickness="1,1,1,1" />
                        <Border Grid.Column="0" 
                                Grid.ColumnSpan="4" 
                                Grid.Row="1"
                                Grid.RowSpan="3"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{StaticResource InControlGroupBorderBrushKey}" 
                                BorderThickness="{TemplateBinding BorderThickness}"
                                CornerRadius="4" />
                        <Border Grid.ColumnSpan="4"
                                Grid.RowSpan="2"
                                Background="{DynamicResource NormalBrush}"
                                BorderThickness="1,1,1,1"
                                CornerRadius="2,2,0,0"
                                x:Name="Main"
                                BorderBrush="{StaticResource InControlGroupBorderBrushKey}" />
                        <Rectangle Opacity="1"
                                   Stroke="{x:Null}" 
                                   Fill="{StaticResource GroupHostBackgroundBrushKey}" 
                                   RadiusX="3"
                                   RadiusY="3"
                                   VerticalAlignment="Stretch"
                                   Height="Auto"
                                   x:Name="Shine"
                                   Grid.ColumnSpan="4"
                                   Grid.RowSpan="2"
                                   Margin="1,1,1,1"/>
                        <Border x:Name="Header"
                                Grid.Column="1"
                                Grid.Row="0"
                                Grid.RowSpan="2"
                                Padding="3,1,3,0">
                            <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                                              ContentSource="Header" 
                                              RecognizesAccessKey="True"
                                              Margin="0,4,0,4" />
                        </Border>
                        <ContentPresenter
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                            Margin="{TemplateBinding Padding}"
                            Grid.Column="1"
                            Grid.ColumnSpan="2" 
                            Grid.Row="2" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <!--TabItem Style-->
    <Style TargetType="{x:Type TabItem}">
        <Setter Property="Foreground" Value="{StaticResource RibbonFontColorBrushKey}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabItem}">
                    <Grid>
                        <Border Name="Border"
                                Margin="0,0,-4,0"
                                Height="21"
                                Background="{StaticResource RibbonTextBoxBackgroundBrushKey}"
                                BorderBrush="{StaticResource InControlGroupBorderBrushKey}" 
                                BorderThickness="1,1,1,1" 
                                CornerRadius="2,12,0,0" >
                            <ContentPresenter x:Name="ContentSite"
                                              VerticalAlignment="Center"
                                              HorizontalAlignment="Center"
                                              ContentSource="Header"
                                              Margin="12,2,12,2"
                                              RecognizesAccessKey="True"/>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter Property="Panel.ZIndex" Value="100" />
                            <Setter TargetName="Border" Property="Background" Value="{StaticResource GroupHostBackgroundBrushKey}" />
                            <Setter TargetName="Border" Property="BorderThickness" Value="1,1,1,0" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="Border" Property="Background" Value="Gray" />
                            <Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource InControlGroupBorderBrushKey}" />
                            <Setter Property="Foreground" Value="White" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <!--CheckBox Style-->
    <Style TargetType="{x:Type CheckBox}">
        <Setter Property="Foreground" Value="{StaticResource RibbonFontColorBrushKey}"/>
    </Style>
    <!--RadioButton Style-->
    <Style TargetType="{x:Type RadioButton}">
        <Setter Property="Foreground" Value="{StaticResource RibbonFontColorBrushKey}"/>
    </Style>
    <!--Label Style-->
    <Style TargetType="{x:Type Label}">
        <Setter Property="Foreground" Value="{StaticResource RibbonFontColorBrushKey}"/>
    </Style>
    <!--TextBlock Style-->
    <Style TargetType="{x:Type TextBlock}">
        <Setter Property="Foreground" Value="{StaticResource RibbonFontColorBrushKey}"/>
    </Style>
    <!--Border Style-->
    <Style x:Key="bBorder" TargetType="{x:Type Border}">
        <Setter Property="CornerRadius" Value="12" />
        <Setter Property="Height" Value="Auto" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="BorderBrush" Value="{StaticResource InControlGroupBorderBrushKey}"/>
        <Setter Property="Background" Value="{StaticResource GroupHostBackgroundBrushKey}"/>
    </Style>
    <Style x:Key="nBorder" TargetType="{x:Type Border}">
        <Setter Property="CornerRadius" Value="2" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="BorderBrush" Value="{StaticResource InControlGroupBorderBrushKey}"/>
    </Style>
    <!--Progressbar Style-->
    <Style TargetType="{x:Type ProgressBar}">
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="BorderBrush" Value="{StaticResource InControlGroupBorderBrushKey}"/>
        <Setter Property="Background" Value="{StaticResource GroupHostBackgroundBrushKey}"/>
        <Setter Property="Foreground" Value="{StaticResource InControlGroupIsPressedBackgroundBrushKey}"/>
    </Style>
    <!--Expander-->
    <Style x:Key="ExpanderHeaderFocusVisual">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Border>
                        <Rectangle Margin="0"
                                   StrokeThickness="1"
                                   Stroke="Black"
                                   StrokeDashArray="1 2"
                                   SnapsToDevicePixels="true"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <LinearGradientBrush x:Key="ExpanderArrowFill"
                         StartPoint="0,0"
                         EndPoint="0,1">
        <LinearGradientBrush.GradientStops>
            <GradientStop Color="White"
                          Offset="0"/>
            <GradientStop Color="#FFBFBFBF"
                          Offset="0.5"/>
            <GradientStop Color="#FF878787"
                          Offset="1"/>
        </LinearGradientBrush.GradientStops>
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="ExpanderArrowHoverFill"
                         StartPoint="0,0"
                         EndPoint="0,1">
        <LinearGradientBrush.GradientStops>
            <GradientStop Color="#FFF0F8FE"
                          Offset="0"/>
            <GradientStop Color="#FFE0F3FE"
                          Offset="0.3"/>
            <GradientStop Color="#FF6FA7C5"
                          Offset="1"/>
        </LinearGradientBrush.GradientStops>
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="ExpanderArrowPressedFill"
                         StartPoint="0,0"
                         EndPoint="0,1">
        <LinearGradientBrush.GradientStops>
            <GradientStop Color="#FFDCF0FA"
                          Offset="0"/>
            <GradientStop Color="#FFC5E6F7"
                          Offset="0.2"/>
            <GradientStop Color="#FF5690D0"
                          Offset="1"/>
        </LinearGradientBrush.GradientStops>
    </LinearGradientBrush>
    <Style x:Key="ExpanderDownHeaderStyle"
           TargetType="{x:Type ToggleButton}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Border Padding="{TemplateBinding Padding}" 
                            BorderThickness="0 0 0 1"
                            BorderBrush="{DynamicResource InControlGroupBorderBrushKey}"
                            Height="25"
                            Margin="0">
                        <Grid Background="{DynamicResource GroupHostBackgroundBrushKey}"
                              SnapsToDevicePixels="False">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="19"/>
                            </Grid.ColumnDefinitions>
                            <Path x:Name="arrow"
                                  Grid.Column="1"
                                  HorizontalAlignment="Center"
                                  VerticalAlignment="Center"
                                  Stroke="#666"
                                  StrokeThickness="2"
                                  SnapsToDevicePixels="false"
                                  Data="M 1,1.5 L 4.5,5 L 8,1.5"/>
                            <ContentPresenter Grid.Column="0"
                                              Margin="5,0,0,0"
                                              HorizontalAlignment="Left"
                                              VerticalAlignment="Center"
                                              SnapsToDevicePixels="True"
                                              RecognizesAccessKey="True"/>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked"
                                 Value="true">
                            <Setter Property="Data"
                                    Value="M 1,4.5  L 4.5,1  L 8,4.5"
                                    TargetName="arrow"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver"
                                 Value="true">
                            <Setter Property="Stroke"
                                    Value="{StaticResource RibbonFontColorBrushKey}"
                                    TargetName="arrow"/>
                            <Setter Property="Cursor"
                                    Value="Hand"/>
                        </Trigger>
                        <Trigger Property="IsPressed"
                                 Value="true">
                            <Setter Property="Stroke"
                                    Value="#FF003366"
                                    TargetName="arrow"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="{x:Type Expander}"
           TargetType="{x:Type Expander}">
        <Setter Property="Foreground"
                Value="{StaticResource RibbonFontColorBrushKey}"/>
        <Setter Property="Background"
                Value="{DynamicResource GroupHostBackgroundBrushKey}"/>
        <Setter Property="HorizontalContentAlignment"
                Value="Stretch"/>
        <Setter Property="VerticalContentAlignment"
                Value="Stretch"/>
        <Setter Property="BorderBrush"
                Value="{DynamicResource InControlGroupBorderBrushKey}"/>
        <Setter Property="BorderThickness"
                Value="1"/>
        <Setter Property="Padding"
                Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Expander}">
                    <Border BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Background="{TemplateBinding Background}"
                            CornerRadius="0"
                            SnapsToDevicePixels="true"
                            Padding="0">
                        <DockPanel>
                            <ToggleButton x:Name="HeaderSite"
                                          DockPanel.Dock="Top"
                                          Margin="0"
                                          MinWidth="0"
                                          MinHeight="0"
                                          Style="{StaticResource ExpanderDownHeaderStyle}"
                                          FocusVisualStyle="{StaticResource ExpanderHeaderFocusVisual}"
                                          IsChecked="{Binding Path=IsExpanded,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}"
                                          Content="{TemplateBinding Header}"
                                          ContentTemplate="{TemplateBinding HeaderTemplate}"
                                          ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"
                                          Foreground="{TemplateBinding Foreground}"
                                          Padding="{TemplateBinding Padding}"
                                          FontFamily="{TemplateBinding FontFamily}"
                                          FontSize="{TemplateBinding FontSize}"
                                          FontStyle="{TemplateBinding FontStyle}"
                                          FontStretch="{TemplateBinding FontStretch}"
                                          FontWeight="{TemplateBinding FontWeight}"
                                          HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
                            <ContentPresenter x:Name="ExpandSite"
                                              DockPanel.Dock="Bottom"
                                              Visibility="Collapsed"
                                              Focusable="false"
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                              Margin="{TemplateBinding Padding}"/>
                        </DockPanel>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsExpanded"
                                 Value="true">
                            <Setter Property="Visibility"
                                    Value="Visible"
                                    TargetName="ExpandSite"/>
                        </Trigger>
                        <Trigger Property="ExpandDirection"
                                 Value="Right">
                            <Setter Property="DockPanel.Dock"
                                    Value="Right"
                                    TargetName="ExpandSite"/>
                            <Setter Property="DockPanel.Dock"
                                    Value="Left"
                                    TargetName="HeaderSite"/>
                            <Setter Property="Style"
                                    Value="{StaticResource ExpanderRightHeaderStyle}"
                                    TargetName="HeaderSite"/>
                        </Trigger>
                        <Trigger Property="ExpandDirection"
                                 Value="Up">
                            <Setter Property="DockPanel.Dock"
                                    Value="Top"
                                    TargetName="ExpandSite"/>
                            <Setter Property="DockPanel.Dock"
                                    Value="Bottom"
                                    TargetName="HeaderSite"/>
                            <Setter Property="Style"
                                    Value="{StaticResource ExpanderUpHeaderStyle}"
                                    TargetName="HeaderSite"/>
                        </Trigger>
                        <Trigger Property="ExpandDirection"
                                 Value="Left">
                            <Setter Property="DockPanel.Dock"
                                    Value="Left"
                                    TargetName="ExpandSite"/>
                            <Setter Property="DockPanel.Dock"
                                    Value="Right"
                                    TargetName="HeaderSite"/>
                            <Setter Property="Style"
                                    Value="{StaticResource ExpanderLeftHeaderStyle}"
                                    TargetName="HeaderSite"/>
                        </Trigger>
                        <Trigger Property="IsEnabled"
                                 Value="false">
                            <Setter Property="Foreground"
                                    Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>